import java.util.Arrays;

public class Test2 {
    public static int Func(int val,int[] array){
        int count = 0;
        int[] temp = new int[array.length];

        for(int i = 0;i < array.length;i++){
            if(array[i] == val){
                array[i] = 0;
                count++;
            }
        }
        int c = 0;

        for(int j = 0 ; j < array.length;j++){

            if(array[j] != 0){
                temp[c] = array[j];
                c++;
            }

        }
        for(int i = 0;i< temp.length;i++){
            array[i] = temp[i];
        }
        return array.length -count;
    }




    public  static int[] func1(int  k,int[] array ){
        k = k % array.length;
        int [] array2 = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            array2[(i + k) % array.length] = array[i];
        }
        for (int j = 0; j < array2.length; j++) {
            array[j] = array2[j];
        }
        return  array;

    }

    public static void main(String[] args) {
        int[] array = {1,5,3,6,3,7,3,4,3};
        int ret = Func(3,array);
        System.out.println(Arrays.toString(array));
        System.out.println(ret);

    }
    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5,6};
        func1(2,array);
        System.out.println(Arrays.toString(array));

    }
}
